package com.framework.wz.wutong.utils;

import android.content.Context;

import com.framework.wz.wutong.base.App;
import com.framework.wz.wutong.base.BasePreference;

/**
 * sharepreference存储数据
 */
public class PreferenceUtils extends BasePreference {

    private static PreferenceUtils preferenceUtils;
    /**
     * 需要增加key就在这里新建
     */
    //用户名的key
    private String USER_NAME = "user_name";
    private String COMPANY_CODE = "companycode";
    private String BIANHAO = "bianhao";
    private String PASSWORD = "password";
    private String REPW = "repw"; // 记住密码
    private String UID = "uid"; // 用户Id

    private PreferenceUtils(Context context) {
        super(context);
    }

    /**
     * 这里我通过自定义的Application来获取Context对象，所以在获取preferenceUtils时不需要传入Context。
     *
     * @return
     */
    public synchronized static PreferenceUtils getInstance() {
        if (null == preferenceUtils) {
            preferenceUtils = new PreferenceUtils(App.getInstance());
        }
        return preferenceUtils;
    }

    public void setUserName(String name) {
        setString("fefe", name);
    }

    public String getUSER_NAME_KEY() {
        return getString(USER_NAME);
    }

    public void setCompanyCode(String companyCode){
        setString(COMPANY_CODE, companyCode);
    }

    public String getCompanyCode(){
        return getString(COMPANY_CODE);
    }

    public void setBianHao(String bianhao){
        setString(BIANHAO, bianhao);
    }

    public String getBianHao(){
        return getString(BIANHAO);
    }

    public void setPassword(String password){
        setString(PASSWORD, password);
    }

    public String getPASSWORD(){
        return getString(PASSWORD);
    }

    public  void setRepw(boolean repw){
        setBoolean(REPW, repw);
    }

    public boolean getRepw(){
        return getBoolean(REPW);
    }

    public  void setUid(String uid){
        setString(UID, uid);
    }

    public String getUid(){
        return getString(UID);
    }
}

